package com.heima.utils.thread;

import com.heima.model.wemedia.pojos.WmUser;

/**
 * 保存用户信息
 */
public class WmThreadLocalUtil {
    private static final ThreadLocal<WmUser> WM_USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 存储用户信息
     * @param user  用户信息
     */
    public static void setUser(WmUser user) {
        WM_USER_THREAD_LOCAL.set(user);
    }

    /**
     * 获取用户信息
     * @return      用户信息
     */
    public static WmUser getUser() {
        return WM_USER_THREAD_LOCAL.get();
    }

    /**
     * 清理用户
     */
    public static void removeUser() {
        WM_USER_THREAD_LOCAL.remove();
    }
}
